NotificationCompat

Helper for accessing features in android.app.Notification.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
open class Action
Structure to encapsulate a named action that can be shown as part of this notification.
Link copied to clipboard
Link copied to clipboard
Helper class for generating large-format notifications that include a large image attachment.
Link copied to clipboard
Helper class for generating large-format notifications that include a lot of text.
Link copied to clipboard
Encapsulates the information needed to display a notification as a bubble.
Link copied to clipboard
open class Builder
Builder class for NotificationCompat objects.
Link copied to clipboard
Helper class for generating large-format notifications that include a caller and required actions, and indicate an incoming call.
Link copied to clipboard
Helper class to add Android Auto extensions to notifications.
Link copied to clipboard
Notification style for custom views that are decorated by the system.
Link copied to clipboard
interface Extender
Extender interface for use with extend.
Link copied to clipboard
Link copied to clipboard
Helper class for generating large-format notifications that include a list of (up to 5) strings.
Link copied to clipboard
Helper class for generating large-format notifications that include multiple back-and-forth messages of varying types between any number of people.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract class Style
An object that can apply a rich notification style to a Notification.Builder object.
Link copied to clipboard
Helper class to add Android TV extensions to notifications.
Link copied to clipboard
Helper class to add wearable extensions to notifications.

Properties

Link copied to clipboard
If this notification is being shown as a badge, use the icon provided to setLargeIcon to represent this notification.
Link copied to clipboard
If this notification is being shown as a badge, always show as a number.
Link copied to clipboard
If this notification is being shown as a badge, use the icon provided to setSmallIcon to represent this notification.
Link copied to clipboard
val CATEGORY_ALARM: String = "alarm"
Notification category: alarm or timer.
Link copied to clipboard
val CATEGORY_CALL: String = "call"
Notification category: incoming call (voice or video) or similar synchronous communication request.
Link copied to clipboard
val CATEGORY_EMAIL: String = "email"
Notification category: asynchronous bulk message (email).
Link copied to clipboard
val CATEGORY_ERROR: String = "err"
Notification category: error in background operation or authentication status.
Link copied to clipboard
val CATEGORY_EVENT: String = "event"
Notification category: calendar event.
Link copied to clipboard
val CATEGORY_LOCATION_SHARING: String = "location_sharing"
Notification category: temporarily sharing location.
Link copied to clipboard
Notification category: incoming direct message (SMS, instant message, etc.).
Link copied to clipboard
val CATEGORY_MISSED_CALL: String = "missed_call"
Notification category: missed call.
Link copied to clipboard
val CATEGORY_NAVIGATION: String = "navigation"
Notification category: map turn-by-turn navigation.
Link copied to clipboard
val CATEGORY_PROGRESS: String = "progress"
Notification category: progress of a long-running background operation.
Link copied to clipboard
val CATEGORY_PROMO: String = "promo"
Notification category: promotion or advertisement.
Link copied to clipboard
val CATEGORY_RECOMMENDATION: String = "recommendation"
Notification category: a specific, timely recommendation for a single thing.
Link copied to clipboard
val CATEGORY_REMINDER: String = "reminder"
Notification category: user-scheduled reminder.
Link copied to clipboard
val CATEGORY_SERVICE: String = "service"
Notification category: indication of running background service.
Link copied to clipboard
val CATEGORY_SOCIAL: String = "social"
Notification category: social network or sharing update.
Link copied to clipboard
val CATEGORY_STATUS: String = "status"
Notification category: ongoing information about device or contextual status.
Link copied to clipboard
val CATEGORY_STOPWATCH: String = "stopwatch"
Notification category: running stopwatch.
Link copied to clipboard
val CATEGORY_SYSTEM: String = "sys"
Notification category: system or device status update.
Link copied to clipboard
val CATEGORY_TRANSPORT: String = "transport"
Notification category: media transport control for playback.
Link copied to clipboard
val CATEGORY_VOICEMAIL: String = "voicemail"
Notification category: voicemail.
Link copied to clipboard
val CATEGORY_WORKOUT: String = "workout"
Notification category: tracking a user's workout.
Link copied to clipboard
Value of color equal to 0 (also known as Color.TRANSPARENT), telling the system not to decorate this notification with any special color but instead use default colors when presenting this notification.
Link copied to clipboard
val DEFAULT_ALL: Int = -1
Use all default values (where applicable).
Link copied to clipboard
Use the default notification lights.
Link copied to clipboard
Use the default notification sound.
Link copied to clipboard
Use the default notification vibrate.
Link copied to clipboard
val EXTRA_ANSWER_COLOR: String = "android.answerColor"
extras key: the color used as a hint for the Answer action button of a android.app.Notification.CallStyle notification.
Link copied to clipboard
val EXTRA_ANSWER_INTENT: String = "android.answerIntent"
extras key: the intent to be sent when the users answers a android.app.Notification.CallStyle notification.
Link copied to clipboard
val EXTRA_AUDIO_CONTENTS_URI: String = "android.audioContents"
Keys into the getExtras Bundle: the audio contents of this notification.
Link copied to clipboard
val EXTRA_BACKGROUND_IMAGE_URI: String = "android.backgroundImageUri"
extras key: A content URI pointing to an image that can be displayed in the background when the notification is selected.
Link copied to clipboard
val EXTRA_BIG_TEXT: String = "android.bigText"
extras key: this is the longer text shown in the big form of a BigTextStyle notification, as supplied to bigText.
Link copied to clipboard
val EXTRA_CALL_IS_VIDEO: String = "android.callIsVideo"
extras key: whether the android.app.Notification.CallStyle notification is for a call that will activate video when answered.
Link copied to clipboard
val EXTRA_CALL_PERSON: String = "android.callPerson"
extras key: the person to be displayed as calling for the android.app.Notification.CallStyle notification.
Link copied to clipboard
val EXTRA_CALL_PERSON_COMPAT: String = "android.callPersonCompat"
extras key: the person to be displayed as calling for the android.app.Notification.CallStyle notification, for Android versions before the Person class was introduced.
Link copied to clipboard
val EXTRA_CALL_TYPE: String = "android.callType"
extras key: the type of call represented by the android.app.Notification.CallStyle notification.
Link copied to clipboard
val EXTRA_CHANNEL_GROUP_ID: String = "android.intent.extra.CHANNEL_GROUP_ID"
Link copied to clipboard
val EXTRA_CHANNEL_ID: String = "android.intent.extra.CHANNEL_ID"
Link copied to clipboard
val EXTRA_CHRONOMETER_COUNT_DOWN: String = "android.chronometerCountDown"
extras key: whether the chronometer set on the notification should count down instead of counting up.
Link copied to clipboard
val EXTRA_COLORIZED: String = "android.colorized"
extras key: whether the notification should be colorized as supplied to setColorized.
Link copied to clipboard
val EXTRA_COMPACT_ACTIONS: String = "android.compactActions"
extras key: the indices of actions to be shown in the compact view, as supplied to (e.g.
Link copied to clipboard
val EXTRA_COMPAT_TEMPLATE: String = "androidx.core.app.extra.COMPAT_TEMPLATE"
extras key: A string representing the name of the specific NotificationCompat.Style used to create this notification.
Link copied to clipboard
val EXTRA_CONVERSATION_TITLE: String = "android.conversationTitle"
extras key: a String to be displayed as the title to a conversation represented by a MessagingStyle.
Link copied to clipboard
val EXTRA_DECLINE_COLOR: String = "android.declineColor"
extras key: the color used as a hint for the Decline or Hang Up action button of a android.app.Notification.CallStyle notification.
Link copied to clipboard
val EXTRA_DECLINE_INTENT: String = "android.declineIntent"
extras key: the intent to be sent when the users declines a android.app.Notification.CallStyle notification.
Link copied to clipboard
val EXTRA_HANG_UP_INTENT: String = "android.hangUpIntent"
extras key: the intent to be sent when the users hangs up a android.app.Notification.CallStyle notification.
Link copied to clipboard
val EXTRA_HIDDEN_CONVERSATION_TITLE: String = "android.hiddenConversationTitle"
Key for compat's getConversationTitle.
Link copied to clipboard
val EXTRA_HISTORIC_MESSAGES: String = "android.messages.historic"
extras key: an array of historicMessagingStyle.Message bundles provided by a MessagingStyle notification.
Link copied to clipboard
val EXTRA_INFO_TEXT: String = "android.infoText"
extras key: this is a small piece of additional text as supplied to setContentInfo.
Link copied to clipboard
val EXTRA_IS_GROUP_CONVERSATION: String = "android.isGroupConversation"
extras key: whether the NotificationCompat.MessagingStyle notification represents a group conversation.
Link copied to clipboard
val EXTRA_LARGE_ICON: String = "android.largeIcon"
extras key: this is a bitmap to be used instead of the small icon when showing the notification payload, as supplied to setLargeIcon.
Link copied to clipboard
val EXTRA_LARGE_ICON_BIG: String = "android.largeIcon.big"
extras key: this is a bitmap to be used instead of the one from setLargeIcon when the notification is shown in its expanded form, as supplied to bigLargeIcon.
Link copied to clipboard
val EXTRA_MEDIA_SESSION: String = "android.mediaSession"
Notification key: A android.media.session.MediaSession.Token associated with a android.app.Notification.MediaStyle notification.
Link copied to clipboard
val EXTRA_MESSAGES: String = "android.messages"
extras key: an array of MessagingStyle.Message bundles provided by a android.app.Notification.MessagingStyle notification.
Link copied to clipboard
val EXTRA_MESSAGING_STYLE_USER: String = "android.messagingStyleUser"
extras key: the person to display for all messages sent by the user, including direct replies to MessagingStyle notifications.
Link copied to clipboard
val EXTRA_NOTIFICATION_ID: String = "android.intent.extra.NOTIFICATION_ID"
Link copied to clipboard
val EXTRA_NOTIFICATION_TAG: String = "android.intent.extra.NOTIFICATION_TAG"
Link copied to clipboard
val EXTRA_PEOPLE: String = "android.people"
extras key: A String array containing the people that this notification relates to, each of which was supplied to addPerson.
Link copied to clipboard
val EXTRA_PEOPLE_LIST: String = "android.people.list"
extras key: : An arrayList of Person objects containing the people that this notification relates to, each of which was supplied to addPerson.
Link copied to clipboard
val EXTRA_PICTURE: String = "android.picture"
extras key: this is a bitmap to be shown in BigPictureStyle expanded notifications, supplied to bigPicture.
Link copied to clipboard
val EXTRA_PICTURE_CONTENT_DESCRIPTION: String = "android.pictureContentDescription"
extras key: this is a content description of the big picture supplied from bigPicture, supplied to setContentDescription.
Link copied to clipboard
val EXTRA_PICTURE_ICON: String = "android.pictureIcon"
extras key: this is an Icon of an image to be shown in Notification.BigPictureStyle expanded notifications, supplied to bigPicture.
Link copied to clipboard
val EXTRA_PROGRESS: String = "android.progress"
extras key: this is the progress value supplied to setProgress.
Link copied to clipboard
val EXTRA_PROGRESS_INDETERMINATE: String = "android.progressIndeterminate"
extras key: whether the progress bar is indeterminate, supplied to setProgress.
Link copied to clipboard
val EXTRA_PROGRESS_MAX: String = "android.progressMax"
extras key: this is the maximum value supplied to setProgress.
Link copied to clipboard
val EXTRA_REMOTE_INPUT_HISTORY: String = "android.remoteInputHistory"
extras key: this is the remote input history, as supplied to setRemoteInputHistory.
Link copied to clipboard
val EXTRA_SELF_DISPLAY_NAME: String = "android.selfDisplayName"
extras key: the username to be displayed for all messages sent by the user including direct replies MessagingStyle notification.
Link copied to clipboard
val EXTRA_SHOW_BIG_PICTURE_WHEN_COLLAPSED: String = "android.showBigPictureWhenCollapsed"
extras key: this is a boolean to indicate that the big picture is to be shown in the collapsed state of a BigPictureStyle notification.
Link copied to clipboard
val EXTRA_SHOW_CHRONOMETER: String = "android.showChronometer"
extras key: whether the when field set using setWhen should be shown as a count-up timer (specifically a android.widget.Chronometer) instead of a timestamp, as supplied to setUsesChronometer.
Link copied to clipboard
val EXTRA_SHOW_WHEN: String = "android.showWhen"
extras key: whether the when field set using setWhen should be shown, as supplied to setShowWhen.
Link copied to clipboard
val EXTRA_SMALL_ICON: String = "android.icon"
extras key: this is the resource ID of the notification's main small icon, as supplied to setSmallIcon.
Link copied to clipboard
val EXTRA_SUB_TEXT: String = "android.subText"
extras key: this is a third line of text, as supplied to setSubText.
Link copied to clipboard
val EXTRA_SUMMARY_TEXT: String = "android.summaryText"
extras key: this is a line of summary information intended to be shown alongside expanded notifications, as supplied to (e.g.
Link copied to clipboard
val EXTRA_TEMPLATE: String = "android.template"
extras key: A string representing the name of the specific android.app.Notification.Style used to create this notification.
Link copied to clipboard
val EXTRA_TEXT: String = "android.text"
extras key: this is the main text payload, as supplied to setContentText.
Link copied to clipboard
val EXTRA_TEXT_LINES: String = "android.textLines"
extras key: An array of CharSequences to show in InboxStyle expanded notifications, each of which was supplied to addLine.
Link copied to clipboard
val EXTRA_TITLE: String = "android.title"
extras key: this is the title of the notification, as supplied to setContentTitle.
Link copied to clipboard
val EXTRA_TITLE_BIG: String = "android.title.big"
extras key: this is the title of the notification when shown in expanded form, e.g.
Link copied to clipboard
val EXTRA_VERIFICATION_ICON: String = "android.verificationIcon"
extras key: the icon to be displayed as a verification status of the caller on a android.app.Notification.CallStyle notification.
Link copied to clipboard
val EXTRA_VERIFICATION_ICON_COMPAT: String = "android.verificationIconCompat"
extras key: the icon to be displayed as a verification status of the caller on a android.app.Notification.CallStyle notification, for Android versions before the Icon class was introduced.
Link copied to clipboard
val EXTRA_VERIFICATION_TEXT: String = "android.verificationText"
extras key: the text to be displayed as a verification status of the caller on a android.app.Notification.CallStyle notification.
Link copied to clipboard
Bit set in the Notification flags field if the notification should be canceled when it is clicked by the user.
Link copied to clipboard
val FLAG_BUBBLE: Int = 4096
Bit set in the Notification flags field if this notification is showing as a bubble.
Link copied to clipboard
Bit set in the Notification flags field if this notification represents a currently running service.
Link copied to clipboard
Bit set in the Notification flags field if this notification is the group summary for a group of notifications.
Link copied to clipboard
Obsolete flag indicating high-priority notifications; use the priority field instead.
Link copied to clipboard
Bit set in the Notification flags field if the audio will be repeated until the notification is cancelled or the notification window is opened.
Link copied to clipboard
val FLAG_LOCAL_ONLY: Int = 256
Bit set in the Notification flags field if this notification is relevant to the current device only and it is not recommended that it bridge to other devices.
Link copied to clipboard
val FLAG_NO_CLEAR: Int = 32
Bit set in the Notification flags field if the notification should not be canceled when the user clicks the Clear all button.
Link copied to clipboard
Bit set in the Notification flags field if this notification is in reference to something that is ongoing, like a phone call.
Link copied to clipboard
Bit set in the Notification flags field if the notification's sound, vibrate and ticker should only be played if the notification is not already showing.
Link copied to clipboard
Bit set in the Notification flags field when LEDs should be turned on for this notification.
Link copied to clipboard
Constant for setGroupAlertBehavior, meaning that all notifications in a group with sound or vibration ought to make sound or vibrate (respectively), so this notification will not be muted when it is in a group.
Link copied to clipboard
Constant for setGroupAlertBehavior, meaning that the summary notification in a group should be silenced (no sound or vibration) even if they would otherwise make sound or vibrate.
Link copied to clipboard
Constant for setGroupAlertBehavior, meaning that all children notification in a group should be silenced (no sound or vibration) even if they would otherwise make sound or vibrate.
Link copied to clipboard
val GROUP_KEY_SILENT: String = "silent"
Constant for the group key that's added to notifications that are not already grouped when setNotificationSilent is used when SDK_INT is >= O.
Link copied to clipboard
val INTENT_CATEGORY_NOTIFICATION_PREFERENCES: String = "android.intent.category.NOTIFICATION_PREFERENCES"
An activity that provides a user interface for adjusting notification preferences for its containing application.
Link copied to clipboard
Maximum number of (generic) action buttons in a notification (contextual action buttons are handled separately).
Link copied to clipboard
Default notification priority for setPriority.
Link copied to clipboard
Higher notification priority for setPriority, for more important notifications or alerts.
Link copied to clipboard
val PRIORITY_LOW: Int = -1
Lower notification priority for setPriority, for items that are less important.
Link copied to clipboard
val PRIORITY_MAX: Int = 2
Highest notification priority for setPriority, for your application's most important items that require the user's prompt attention or input.
Link copied to clipboard
val PRIORITY_MIN: Int = -2
Lowest notification priority for setPriority; these items might not be shown to the user except under special circumstances, such as detailed notification logs.
Link copied to clipboard
Use this constant as the value for audioStreamType to request that the default stream type for notifications be used.
Link copied to clipboard
Notification visibility: Show this notification on all lockscreens, but conceal sensitive or private information on secure lockscreens.
Link copied to clipboard
Notification visibility: Show this notification in its entirety on all lockscreens.
Link copied to clipboard
Notification visibility: Do not reveal any part of this notification on a secure lockscreen.

Functions

Link copied to clipboard
open fun getAction(@NonNull notification: Notification, actionIndex: Int): NotificationCompat.Action
Get an action on this notification in a backwards compatible manner.
Link copied to clipboard
open fun getActionCount(@NonNull notification: Notification): Int
Get the number of actions in this notification in a backwards compatible manner.
Link copied to clipboard
Returns whether the platform is allowed (by the app developer) to generate contextual actions for this notification.
Link copied to clipboard
open fun getAutoCancel(@NonNull notification: Notification): Boolean
Get the value provided to setAutoCancel
Link copied to clipboard
open fun getBadgeIconType(@NonNull notification: Notification): Int
Returns what icon should be shown for this notification if it is being displayed in a Launcher that supports badging.
Link copied to clipboard
Get the BubbleMetadata for a notification that will be used to display app content in a floating window over the existing foreground activity.
Link copied to clipboard
open fun getCategory(@NonNull notification: Notification): String
Get the category of this notification in a backwards compatible manner.
Link copied to clipboard
open fun getChannelId(@NonNull notification: Notification): String
Link copied to clipboard
open fun getColor(@NonNull notification: Notification): Int
Get the value provided to setColor
Link copied to clipboard
Returns the content info provided to setContentInfo.
Link copied to clipboard
Returns the content text provided to setContentText.
Link copied to clipboard
Returns the content title provided to setContentTitle.
Link copied to clipboard
open fun getExtras(@NonNull notification: Notification): Bundle
Gets the extras field from a notification in a backwards compatible manner.
Link copied to clipboard
open fun getGroup(@NonNull notification: Notification): String
Get the key used to group this notification into a cluster or stack with other notifications on devices which support such rendering.
Link copied to clipboard
open fun getGroupAlertBehavior(@NonNull notification: Notification): Int
Returns which type of notifications in a group are responsible for audibly alerting the user.
Link copied to clipboard
Returns the invisible actions contained within the given notification.
Link copied to clipboard
open fun getLocalOnly(@NonNull notification: Notification): Boolean
Get whether or not this notification is only relevant to the current device.
Link copied to clipboard
Gets the LocusIdCompat associated with this notification.
Link copied to clipboard
open fun getOngoing(@NonNull notification: Notification): Boolean
Get the value provided to setOngoing
Link copied to clipboard
open fun getOnlyAlertOnce(@NonNull notification: Notification): Boolean
Get the value provided to setOnlyAlertOnce
Link copied to clipboard
open fun getPeople(@NonNull notification: Notification): List<Person>
Returns the people in the notification.
Link copied to clipboard
Get the value provided to setVisibility
Link copied to clipboard
Returns the settings text provided to setSettingsText.
Link copied to clipboard
open fun getShortcutId(@NonNull notification: Notification): String
Returns the id that this notification supersedes, if any.
Link copied to clipboard
open fun getShowWhen(@NonNull notification: Notification): Boolean
Get the value provided to setShowWhen
Link copied to clipboard
open fun getSortKey(@NonNull notification: Notification): String
Get a sort key that orders this notification among other notifications from the same package.
Link copied to clipboard
Returns the sub text provided to setSubText.
Link copied to clipboard
open fun getTimeoutAfter(@NonNull notification: Notification): Long
Returns the time at which this notification should be canceled by the system, if it's not canceled already.
Link copied to clipboard
open fun getUsesChronometer(@NonNull notification: Notification): Boolean
Get the value provided to setUsesChronometer
Link copied to clipboard
open fun getVisibility(@NonNull notification: Notification): Int
Get the value provided to setVisibility
Link copied to clipboard
open fun isGroupSummary(@NonNull notification: Notification): Boolean
Get whether this notification to be the group summary for a group of notifications.
Link copied to clipboard
Reduces the size of a provided icon if it's larger than the maximum allowed for a notification large icon; returns the resized icon.